<template>
  <el-dialog width="1200px" :title="$t('m.sigin.siginresult')" :visible.sync="popupVisible" :before-close="close">
    <!-- tool start -->
    <el-form align="left" ref="form" :model="detail" label-width="120px">
      <el-row>
        <el-col :span="8">
          <el-form-item label="sku">
            <el-input disabled v-model="detail.productspeccode" autocomplete="off"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="supplierCode">
            <el-input disabled v-model="detail.suppliercode" autocomplete="off"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('m.in.productspec')">
            <el-input maxlength="20" show-word-limit v-model="detail.productspec" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item :label="$t('m.in.productname')">
            <el-input maxlength="20" show-word-limit v-model="detail.productname" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('m.sigin.sigin')">
            <el-input maxlength="20" show-word-limit v-model="actualquantity" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('m.sigin.tsareacode')">
            <el-input maxlength="20" show-word-limit v-model="detail.tsareacode" disabled></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <!-- tool end -->

    <!-- table start -->
    <el-row>
      <el-col :span="24">
         <el-table
          ref="table"
          :data="detail.signindetailitemList"
          stripe
          empty-text
          fit
          tooltip-effect="dark">
          <el-table-column align="center" type="index" :label="$t('m.index')" width="50"></el-table-column>
          <el-table-column align="center" prop="signquantity" :label="$t('m.sigin.signquantity')"></el-table-column>
          <el-table-column align="center" prop="tasknumber" :label="$t('m.sigin.tasknumber')"></el-table-column>
          <el-table-column align="center" prop="productiondate" :label="$t('m.sigin.productiondate')">
            <template slot-scope="scope">{{scope.row.productiondate}}</template>
          </el-table-column>
          <el-table-column align="center" prop="expirydate" :label="$t('m.sigin.expirydate')">
            <template slot-scope="scope">{{scope.row.expirydate}}</template>
          </el-table-column>
          <el-table-column align="center" prop="containercode" :label="$t('m.page.container')+$t('m.code')"></el-table-column>
          <el-table-column align="center" prop :label="$t('m.operation')">
            <template slot-scope="scope">
              <el-button type="primary" size="mini" @click="print(scope.row.tasknumber)" v-if="hasPermission('print')">{{$t('m.print')}}</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-col>
    </el-row>
    <!-- table end -->
    <el-row>
      <el-col :span="24" align="center">
        <el-button @click="close">{{$t('m.close')}}</el-button>
      </el-col>
    </el-row>
  </el-dialog>
</template>
<script>
import { getLodop } from '@/utils/LodopFuncs'
export default {
  name:'signing-result-popup',
  props:['popupVisible', 'detail'],
  data(){
    return {
      remark:'',
      printContent:''
    }
  },
  computed:{
    actualquantity(){
      return this.detail.actualquantity
    }
  },
  methods:{
    close(){
      this.$emit('close')
    },
    print(tasknumber){
      let LODOP = getLodop()
      let that = this
      that
        .$axios({
          method:'post',
          url:'/printtemplate/printsign',
          data:[tasknumber]
        })
        .then(({data})=> {
          that.printContent = data
          eval(that.printContent)
          LODOP.SET_PRINT_PAGESIZE(1, '50mm', '30mm', '')
          LODOP.PREVIEW()
        })
    }
  }
}
</script>